        var cncaStore = new Ext.data.JsonStore({
			url: '/weihe/get_cncaList',
			root: 'datas',
			fields : [{
						name:'CncaId',mapping:'id'
					},{
						name:'CncaCompany',mapping:'company'
					},{
						name:'CncaCoa',mapping:'coa'
					},{
						name:'CncaContact',mapping:'contact'
					},{
						name:'CncaTel',mapping:'tel'
				    },{
				    	name:'CncaFax',mapping:'fax'
				    },{
				    	name:'CncaEmail',mapping:'email'
				    },{
				    	name:'CncaImporter',mapping:'importer'
				    },{
				    	name:'CncaExporter',mapping:'exporter'
				    },{
				    	name:'CncaNum',mapping:'num'
				    },{
				    	name:'CncaValue',mapping:'value'
				    },{
				    	name:'CncaCode',mapping:'code'
				    },{
				    	name:'CncaGoods',mapping:'goods'
				    },{
				    	name:'CncaQoc20',mapping:'qoc20'
				    },{
				    	name:'CncaQoc40',mapping:'qoc40'
				    },{
				    	name:'CncaBlNum',mapping:'blNum'
				    },{
				    	name:'CncaContainerNum',mapping:'containerNum'
				    },{
				    	name:'CncaPackages',mapping:'packages'
				    },{
				    	name:'CncaFreight',mapping:'freight'
				    },{
				    	name:'CncaCl',mapping:'cl'
				    },{
				    	name:'CncaCl20',mapping:'cl20'
				    },{
				    	name:'CncaCl40',mapping:'cl40'
				    },{
				    	name:'CncaBulk',mapping:'bulk'
				    },{
				    	name:'CncaReefer',mapping:'reefer'
				    },{
				    	name:'CncaLoadingPort',mapping:'loadingPort'
				    },{
				    	name:'CncaCol',mapping:'col'
				    },{
				    	name:'CncaDol',mapping:'dol',type : 'date', dateFormat:"Y-m-d"
				    },{
				    	name:'CncaDp',mapping:'dp'
				    },{
				    	name:'CncaEta',mapping:'eta'
				    },{
				    	name:'CncaSs',mapping:'ss'
				    },{
				    	name:'CncaLcompany',mapping:'lcompany'
				    },{
				    	name:'CncaLaddress',mapping:'laddress'
				    },{
				    	name:'CncaLtel',mapping:'ltel'
				    },{
				    	name:'CncaPic',mapping:'pic'
				    }],
					listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_cncaList',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
    	
    	

cnca = function(){
	var tmp;
  return{
     
	  cncaGrid : function(){

		var pageToolBar = new Ext.PagingToolbar({
			pageSize : 15,
			store : cncaStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
		   
		});


		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		
	   var cncaGrid = new Ext.grid.GridPanel({
		   id:'cncaGrid',
		   title : 'CNCA信息表',
		   region : 'center',
		   minColumnWidth : 50,
		   loadMask : {msg:'正在加载数据，请稍侯...'},
		   tbar:[{
			  	text:"打印CNCA",
				handler:function(){
							if(tmp!=''){
			   				window.open('/weihe/printCncaList?cncaList.id='+ tmp, '_blank');
			   				tmp = '';
							}else{
								Ext.Msg.alert('提示','请选择要打印的数据!');
							}
				}
						
		   		},"-"],
		   store : cncaStore,
		   columns: [
		             {header : '公司名称', dataIndex : 'CncaCompany', menuDisabled : true},
		             {header : 'COMPANY OF APPLICANT', dataIndex : 'CncaCoa', menuDisabled : true},
		             {header : 'CONTACT', dataIndex : 'CncaContact'},
		             {header : 'TEL', dataIndex : 'CncaTel', menuDisabled : true},
		             {header : 'FAX', dataIndex : 'CncaFax', menuDisabled : true},
		             {header : 'EMAIL', dataIndex : 'CncaEmail', menuDisabled : true},
		             {header : '收货人', dataIndex : 'CncaImporter', menuDisabled : true},
		             {header : '发货人', dataIndex : 'CncaExporter', menuDisabled : true},
		             {header : 'HS CODE', dataIndex : 'CncaNum', menuDisabled : true},
		             {header : '货品价值', dataIndex : 'CncaValue', menuDisabled : true},
		             {header : '商品编码', dataIndex : 'CncaCode', menuDisabled : true},
		             {header : '货名', dataIndex : 'CncaGoods', menuDisabled : true},
		             {header : 'QUANTITY 20X', dataIndex : 'CncaQoc20', menuDisabled : true},
		             {header : 'QUANTITY 40X', dataIndex : 'CncaQoc40', menuDisabled : true},
		             {header : 'B/L NO.', dataIndex : 'CncaBlNum', menuDisabled : true},
		             {header : '柜号', dataIndex : 'CncaContainerNum', menuDisabled : true},
		             {header : '总件数', dataIndex : 'CncaPackages', menuDisabled : true},
		             {header : 'FREIGHT', dataIndex : 'CncaFreight', menuDisabled : true},
		             {header : 'CONVENTIONAL', dataIndex : 'CncaCl', menuDisabled : true},
		             {header : 'CONVENTIONAL 20', dataIndex : 'CncaCl20', menuDisabled : true},
		             {header : 'CONVENTIONAL 40', dataIndex : 'CncaCl40', menuDisabled : true},
		             {header : 'BULK', dataIndex : 'CncaBulk', menuDisabled : true},
		             {header : 'REEFER', dataIndex : 'CncaReefer', menuDisabled : true},
		             {header : '装货港', dataIndex : 'CncaLoadingPort', menuDisabled : true},
		             {header : '原产地', dataIndex : 'CncaCol', menuDisabled : true},
		             {header : '目地港', dataIndex : 'CncaDp', menuDisabled : true},
		             {header : '装货日期', dataIndex : 'CncaDol',sortable : true,renderer:Ext.util.Format.dateRenderer('Y年m月d日')},
		             {header : 'E.T.A', dataIndex : 'CncaEta', menuDisabled : true},
		             {header : '船名及航次', dataIndex : 'CncaSs', menuDisabled : true},
		             {header : '（收）公司名称', dataIndex : 'CncaLcompany', menuDisabled : true},
		             {header : '（收）地址', dataIndex : 'CncaLaddress', menuDisabled : true},
		             {header : '（收）电话', dataIndex : 'CncaLtel', menuDisabled : true},
		             {header : '收件人', dataIndex : 'CncaPic', menuDisabled : true}
        ],
           sm : rowSelectionModel,
           listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   var record = grid.getStore().getAt(rowIndex);
			   Ext.getCmp("cncaForm").form.loadRecord(record);
			   tmp = record.get('CncaId');
			   Ext.getCmp("cncaForm").buttons[0].setText('修改');
		   }
		},
		  viewConfig : {
		     forceFit : false
		  },
		  bbar : pageToolBar
});
		return cncaGrid;
	},
	cncaForm : function(){

		var button_add = new Ext.Button({
			text : '添加',
			handler : function() {

					progressConsole();
				if(cncaForm.form.isValid()){ 	
					if (cncaForm.form.findField("cncaList.id").getValue() == "") {
						cncaForm.form.submit({
						  url : '/weihe/add_cncaList',
						   success : function(form, action) {
							 if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
							  }else{
								Ext.Msg.alert('消息', action.result.msg, function() {
									cncaForm.form.reset();
									   Ext.getCmp("cncaGrid").getStore().reload();
									
								});
							  }
						    }
					    });
					}else {
						cncaForm.form.submit({
							  url : '/weihe/update_cncaList',
							   success : function(form, action) {
								 if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
								  }else{
									Ext.Msg.alert('消息', action.result.msg, function() {
										cncaForm.form.reset();
										Ext.getCmp("cncaGrid").getStore().reload();
										cncaForm.buttons[0].setText('添加');
										
									});
								  }
							    }
						    });
					}
			}else{
				Ext.Msg.alert('提示','请输入相关内容');
			}
				}
		
			
		});

	var button_clear = new Ext.Button({
		id : 'button_clear',
		text : '清空',
		handler : function() {
			cncaForm.form.reset();
			cncaForm.buttons[0].setText('添加');
		}
	});

	var button_del = new Ext.Button({
		text : '删除',
		handler : function() {
			var id = cncaForm.form.findField('cncaList.id').getValue();
			if (id == '') {
				Ext.Msg.alert('提示', '请选择需要删除的信息!');
			} else {
				progressConsole();
				Ext.Ajax.request({
					url : '/weihe/delete_cncaList',
					success : function(response) {
						var json = Ext.decode(response.responseText);
						if (json.success) {
							if (json.deny) {
									Ext.Msg.alert('错误',json.msg);
									cncaForm.form.reset();
									cncaForm.buttons[0].setText('添加');
						  }else{
							Ext.Msg.alert('消息', json.msg, function() {
								Ext.getCmp("cncaGrid").getStore().load({params : {start : 0, limit : 15}});
								cncaForm.form.reset();
								cncaForm.buttons[0].setText('添加');
							});
						  }
						}else{
							Ext.Msg.alert('消息', json.msg);
							cncaForm.form.reset();
							cncaForm.buttons[0].setText('添加');
						}
					},
					failure : function() {
						Ext.Msg.alert('错误', '删除失败!');
					},
					params : 'cncaList.id=' + id
				});
			}
		}
	});
	
	

	var  cncaForm = new Ext.form.FormPanel({
		id : 'cncaForm',
		title : '结算信息',
		frame : true,
		width : 350,
		region : 'east',
		autoScroll : true,
		labelAlign : 'right',
		labelWidth : 80,
		defaultType : 'textfield',
			defaults : {
			width : 200
		},
		items : [{  // Ext.form.Hidden
			id:'CncaId',
			xtype : 'hidden',  // 隐藏的表单
			name : 'cncaList.id'
		},{
			id:'CncaCompany',
			fieldLabel : '公司名称',
			name : 'cncaList.company',
			allowBlank:false,
			blankText:'请输入公司名称'
		},{
			id:'CncaCoa',
			fieldLabel : 'APPLICANT',
			allowBlank:false,
			blankText:'请输入APPLICANT',
			name : 'cncaList.coa'
		},{
			id:'CncaContact',
			fieldLabel : 'CONTACT',
			allowBlank:false,
			blankText:'请输入CONTACT',
			name : 'cncaList.contact'
		},{
			id:'CncaTel',
			fieldLabel : 'Tel',
			name : 'cncaList.tel',
			allowBlank:false,
			blankText:'请输入TEL'
		},{
			id:'CncaFax',
			fieldLabel : 'FAX',
			name : 'cncaList.fax',
			allowBlank:false,
			blankText:'请输入FAX'
		},{
			id:'CncaEmail',
			fieldLabel : 'EMAIL',
			name : 'cncaList.email',
			allowBlank:false,
			blankText:'请输入EMAIL'
		},{
			id:'CncaImporter',
			fieldLabel : '收货人',
			name : 'cncaList.importer',
			allowBlank:false,
			blankText:'请输入收货人'
		},{
			id:'CncaExporter',
			fieldLabel : '发货人',
			name : 'cncaList.exporter',
			allowBlank:false,
			blankText:'请输入发货人'
		},{
			id:'CncaNum',
			fieldLabel : 'HSCODE',
			name : 'cncaList.num',
			allowBlank:false,
			blankText:'请输入HSCODE'
		},{
			id:'CncaValue',
			fieldLabel : '货品价值',
			name : 'cncaList.value',
			allowBlank:false,
			blankText:'请输入货品价值'
		},{
			id: 'CncaCode',
			xtype: 'textarea',
			name: 'cncaList.code',
			fieldLabel: '商品编码',
			height: 45
		},{
			id: 'CncaGoods',
			xtype: 'textarea',
			name: 'cncaList.goods',
			fieldLabel: '货名',
			height: 45
		},{
			id:'CncaQoc20',
			fieldLabel : '20X',
			name : 'cncaList.qoc20',
			allowBlank:false,
			blankText:'请输入20X'
		},{
			id:'CncaQoc40',
			fieldLabel : '40X',
			name : 'cncaList.qoc40',
			allowBlank:false,
			blankText:'请输入40X'
		},{
			id:'CncaBlNum',
			fieldLabel : 'B/LNO.',
			name : 'cncaList.blNum',
			allowBlank:false,
			blankText:'请输入B/LNO.'
		},{
			id:'CncaContainerNum',
			fieldLabel : '柜号',
			name : 'cncaList.containerNum',
			allowBlank:false,
			blankText:'请输入柜号'
		},{
			id:'CncaPackages',
			fieldLabel : '总件数',
			name : 'cncaList.packages',
			allowBlank:false,
			blankText:'请输入总件数'
		},{
			id:'CncaFreight',
			fieldLabel : 'FREIGHT',
			name : 'cncaList.freight',
			allowBlank:false,
			blankText:'请输入FREIGHT'
		},{
			id:'CncaCl',
			fieldLabel : 'CL',
			name : 'cncaList.cl',
			allowBlank:false,
			blankText:'请输入CONVENTIONAL'
		},{
			id:'CncaCl20',
			fieldLabel : '20',
			name : 'cncaList.cl20',
			allowBlank:false,
			blankText:'请输入20'
		},{
			id:'CncaCl40',
			fieldLabel : '40',
			name : 'cncaList.cl40',
			allowBlank:false,
			blankText:'请输入40'
		},{
			id:'CncaBulk',
			fieldLabel : 'BULK',
			name : 'cncaList.bulk',
			allowBlank:false,
			blankText:'请输入BULK'
		},{
			id:'CncaReefer',
			fieldLabel : 'REEFER',
			name : 'cncaList.reefer',
			allowBlank:false,
			blankText:'请输入REEFER'
		},{
			id:'CncaLoadingPort',
			fieldLabel : '装货港',
			name : 'cncaList.loadingPort',
			allowBlank:false,
			blankText:'请输入装货港'
		},{
			id:'CncaCol',
			fieldLabel : '原产地',
			name : 'cncaList.col',
			allowBlank:false,
			blankText:'请输入原产地'
		},{
			id:'CncaDp',
			fieldLabel : '目地港',
			name : 'cncaList.dp',
			allowBlank:false,
			blankText:'请输入目地港'
		},{
			id: 'CncaDol',
            xtype: 'datefield',
            fieldLabel: "装货日期",
            format : 'Y-m-d',
    		allowBlank:false,
            name: "cncaList.dol"
		},{
			id:'CncaEta',
			fieldLabel : 'E.T.A',
			name : 'cncaList.eta',
			allowBlank:false,
			blankText:'请输入E.T.A'
		},{
			id:'CncaSs',
			fieldLabel : '船名船次',
			name : 'cncaList.ss',
			allowBlank:false,
			blankText:'请输入船名船次'
		},{
			id:'CncaLcompany',
			fieldLabel : '（收）公司名称',
			name : 'cncaList.lcompany',
			allowBlank:false,
			blankText:'请输入（收）公司名称'
		},{
			id:'CncaLaddress',
			fieldLabel : '（收）地址',
			name : 'cncaList.laddress',
			allowBlank:false,
			blankText:'请输入（收）地址'
		},{
			id:'CncaLtel',
			fieldLabel : '（收）电话',
			name : 'cncaList.ltel',
			allowBlank:false,
			blankText:'请输入（收）电话'
		},{
			id:'CncaPic',
			fieldLabel : '收件人',
			name : 'cncaList.pic',
			allowBlank:false,
			blankText:'请输入收件人'
		}],
		buttons : [button_add,button_clear,button_del]
	});
		return  cncaForm;
	}
  }
}();